package top.soulblack.purchasesale.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.GoodsUnitMapper;
import top.soulblack.purchasesale.model.GoodsUnit;
import top.soulblack.purchasesale.model.GoodsUnit;

import java.util.List;

/**
 * @Author: 廉雪峰
 * @Date: 2019/5/19 20:25
 * @Version 1.0
 */
@Service
public class GoodsUnitService {

    @Autowired
    private GoodsUnitMapper goodsUnitMapper;

    public List<GoodsUnit> selectAll() {
        return goodsUnitMapper.selectAll();
    }

    public void addUnit(GoodsUnit goodsUnit) {
        goodsUnitMapper.addUnit(goodsUnit);
        return;
    }

    public boolean existUnit(String name) {
        int num  = goodsUnitMapper.existUnit(name);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteUnit(int UnitId) {
        int num = goodsUnitMapper.deleteByPrimaryKey(UnitId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateUnit(GoodsUnit goodsUnit) {
        int num = goodsUnitMapper.updateByPrimaryKey(goodsUnit);
        if (num == 1) {
            return true;
        }
        return false;
    }
}
